//
//  RunInfo.m
//  SportSocial
//
//  Created by yull on 15/2/4.
//  Copyright (c) 2015年 yull. All rights reserved.
//

#import "RunInfo.h"

@implementation RunInfo

+ (instancetype)runInfoWithResultSet:(FMResultSet *)resultSet
{
    RunInfo *runInfo = [[RunInfo alloc] init];
    runInfo.dbId = [resultSet longLongIntForColumn:@"id"];
    runInfo.planId = [resultSet longLongIntForColumn:@"planId"];
    runInfo.locate_date = [resultSet doubleForColumn:@"locate_date"];
    runInfo.altitude = [resultSet doubleForColumn:@"altitude"];
    runInfo.longitude = [resultSet doubleForColumn:@"longitude"];
    runInfo.latitude = [resultSet doubleForColumn:@"latitude"];
    runInfo.speed = [resultSet doubleForColumn:@"speed"];
    runInfo.bearing = [resultSet doubleForColumn:@"bearing"];
    runInfo.accuracy = [resultSet doubleForColumn:@"accuracy"];
    return runInfo;
}

+ (instancetype)runInfoWithLocation:(CLLocation *)location
{
    RunInfo *runInfo = [[RunInfo alloc] init];
    runInfo.altitude = location.altitude;
    runInfo.latitude = location.coordinate.latitude;
    runInfo.longitude = location.coordinate.longitude;
    runInfo.locate_date = [location.timestamp timeIntervalSince1970];
    runInfo.speed = location.speed;
    runInfo.bearing = location.course;
    runInfo.accuracy = [BMKLocationService getCurrentLocationDesiredAccuracy];
    return runInfo;
}
@end
